// 引入vue3路由 createRouter:用来创建路由对象
import { createRouter,createWebHashHistory } from 'vue-router';
// createRouter:最少传递一个配置对象
const router = createRouter({
    history:createWebHashHistory(),
    routes:[
      {
        name:'home',
        path:'/home',
        component:()=>import('@/pages/home/Home.vue'),
        meta:{
          title:'首页'
        },
        // 一级路由的重定向
        redirect:'/home/news',
        children:[
          {
            name:'news',
            path:'news',
            component:()=>import('@/pages/home/news/News.vue'),
            meta:{
              title:'新闻'
            }
          },
          {
            name:'message',
            path:'message',
            component:()=>import('@/pages/home/message/Message.vue'),
            meta:{
              title:'消息'
            }
          },
        ]
      },
      {
        name:'about',
        path:'/about',
        component:()=>import('@/pages/about/About.vue'),
        meta:{
          title:'关于'
        }
      },
      // 路由重定向
      {
        path:'/',
        redirect:'/home'
      },
      {
        name: 'NotFound',
        path:'/:pathMatch(.*)*',
        component:()=>import('@/pages/404/404.vue'),
        meta:{
          title:'404 NOT Found'
        }
      }
    ]
})


export default router